#include <sqlite3.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <stdlib.h>
#include "MQTTClient.h"
#include "cJSON.h"
#include <unistd.h>
#include "shmem.h"
#include "msg_queue_peer.h"
#include <stdbool.h>
#include <time.h>
#include "pub_define.h"

#define data_db_path "/home/hq/c/config/data_manage.db"
#define QOS 1
#define TIMEOUT 10000L
#define TOPIC1 "up"
#define TOPIC2 "down"


typedef struct msgbuf
{
    long mtype;
    int mkey;
    char value[16];
    int addr;
} msgbuf_t, *msgbuf_p;

int msgarrvd(void *context, char *topicName, int topicLen, MQTTClient_message *message);
void history_report(cJSON *root);
int report_callback(void *data, int argc, char **argv, char **azColName);
void send_history_report_directly(const char *report_data);